package com.wsj.a.collapsingdemo.ui;

import android.app.Activity;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;

import com.umeng.socialize.UMShareAPI;
import com.wsj.a.collapsingdemo.MainActivity;
import com.wsj.a.collapsingdemo.R;
import com.wsj.a.collapsingdemo.adapter.SplashImageAdapter;
import com.wsj.a.collapsingdemo.databinding.ActivitySplashBinding;
import com.wsj.a.collapsingdemo.widget.ScrollLinearLayoutManager;

/**
 * Created by linxiujie on 2018/8/15.
 * TODO：启动页
 */

public class SplashActivity extends Activity {
    ActivitySplashBinding mBinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(SplashActivity.this,R.layout.activity_splash);
        mBinding.setOnClick(this);
        //全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


        mBinding.recylerView.setAdapter(new SplashImageAdapter(SplashActivity.this));
        mBinding.recylerView.setLayoutManager(new ScrollLinearLayoutManager(SplashActivity.this));

        //smoothScrollToPosition滚动到某个位置（有滚动效果）
        mBinding.recylerView.smoothScrollToPosition(Integer.MAX_VALUE / 2);

    }

    public void onHomeBtnClick(View view){
        Intent intent = new Intent(SplashActivity.this, MainActivity.class);
        startActivity(intent);
    }

    public void onLoginBtnClick(View view){
        Intent intent = new Intent(SplashActivity.this,LoginActivity.class);
        startActivity(intent);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //分享的回调
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);//完成回调
    }
}
